package book;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:书架，用于存储图书
 * User: 阿宾
 * Date: 2024-06-17
 * Time: 17:58
 */
public class BookList {
    private Book[] books = new Book[10];//创建大小为10的书架，通过创建Book类型的数组实现

    private int usedSize;//计数器，统计当前实际存放的书的数量

    public BookList() {
       //构造方法，初始化成员
        this.books[0] = new Book("三国演义","罗贯中",15,"小说");
        this.books[1] = new Book("西游记","吴承恩",20,"小说");
        this.books[2] = new Book("红楼梦","曹雪芹",30,"小说");
        this.usedSize = 3;
    }

    public Book getBook(int pos){//给一个书架位置，获得对应位置的书
        return books[pos];
    }

    public void setBooks(int pos,Book book) {//给一个书架位置，把书放到对应位置
        books[pos] = book;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
}
